package com.itheima.vo;

import com.itheima.domain.db.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserLikeVo implements Serializable {

    private Long id;
    private String avatar;
    private String nickname;
    private String gender;
    private Integer age;
    private String city;
    private String education;
    private Integer marriage; //婚姻状态（0未婚，1已婚）
    private Integer matchRate=66; //匹配度
    private boolean alreadyLove = false;//是否喜欢它

    public static UserLikeVo init(UserInfo userInfo, Integer matchRate, Boolean alreadyLove){

        UserLikeVo userVo = new UserLikeVo();
        if (!ObjectUtils.isEmpty(userInfo)){
            BeanUtils.copyProperties(userInfo, userVo);
        }
        if (matchRate != null) {
            userVo.setMatchRate(matchRate);
        }
        if (alreadyLove != null){
            userVo.setAlreadyLove(alreadyLove);
        }
        return userVo;
    }
}